<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./lib/vue-2.4.0.js"></script>
    <link rel="stylesheet" href="./lib/bootstrap-3.3.7.css">
    <script src="https://cdn.staticfile.org/axios/0.18.0/axios.min.js"></script>
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <!-- 需要用到Jquery吗？？？ -->
</head>
<body>
<div class="container" id="app">
    <div class="row">
        <div class="col-md-12">
            <nav class="navbar navbar-default">
                <div class="container-fluid">
                    <!-- Brand and toggle get grouped for better mobile display -->
                    <div class="navbar-header">
                        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                                data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                            <span class="sr-only">Toggle navigation</span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                            <span class="icon-bar"></span>
                        </button>
                        <a class="navbar-brand" href="#">管理员管理</a>
                    </div>

                    <!-- Collect the nav links, forms, and other content for toggling -->
                    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                        <ul class="nav navbar-nav">
                            <li>
                                <a href="/schoolSchedule.html">全校课程</a>
                            </li>
                            <li>
                                <a href="/studentResult.html">学生成绩</a>
                            </li>
                            <li>
                                <a href="/studentSchedule.html">学生课程</a>
                            </li>
                            <li>
                                <a href="/trainingPlan.html">培养方案</a>
                            </li>
                            <li>
                                <a href="/rebuild.html">重修/改修</a>
                            </li>
                            <li class="active">
                                <a href="/">上传</a>
                            </li>
                        </ul>

                        <ul class="nav navbar-nav navbar-right">
                            <li class="dropdown">
                                <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button"
                                   aria-haspopup="true" aria-expanded="false">欢迎您，老师<span
                                        class="caret"></span></a>
                                <ul class="dropdown-menu">
                                    <li>
                                        <a href="/loginout">退出</a>
                                    </li>
                                    <li>
                                        <p data-toggle="modal" data-target="#myModal">重置密码</p>
                                    </li>
                                </ul>
                            </li>
                        </ul>
                    </div>
                    <!-- /.navbar-collapse -->
                </div>
                <!-- /.container-fluid -->
            </nav>

        </div>
    </div>
    <div class="row">
        <div class="col-md-6">
            <form action="/uploads" method="post" enctype="multipart/form-data">
                <p>文件上传</p>
                <input type="file" name="file" multiple="multiple">
                <p><input type="submit" value="提交"></p>
            </form>
        </div>
        <div class="col-md-6" >
            <div class="row">
                <div class="col-md-12" style="margin-top: 100px">
                    <button type="button" class="btn btn-primary" @click="uptable('sc')">清空全校课程表</button>
                </div>
                <div class="col-md-12" style="margin-top: 100px">
                    <button type="button" class="btn btn-success" @click="uptable('st')">清空学生课程表</button>
                </div>
                <div class="col-md-12" style="margin-top: 100px">
                    <button type="button" class="btn btn-primary" @click="uptable('t')">清空培养方案</button>
                </div>
                <div class="col-md-12" style="margin-top: 100px" >
                    <button type="button" class="btn btn-info" @click="uptable('sr')">清空学生成绩</button>
                </div>
                <div class="col-md-12" style="margin-top: 100px" >
                    <button type="button" class="btn btn-warning" @click="uptable('all')">清空所有数据</button>
                </div>
            </div>


        </div>
    </div>
    <!-- 模态框（Modal） -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        详情
                    </h4>
                </div>
                <div class="modal-body">
                    <form class="form-horizontal">
                        <div class="form-group">
                            <label for="inputEmail3" class="col-sm-2 control-label">旧密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" id="inputEmail3" placeholder="旧密码" v-model="password">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">新密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" id="inputPassword3" placeholder="新密码" v-model="newpass">
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="inputPassword3" class="col-sm-2 control-label">确认新密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" id="" placeholder="确认新密码" v-model="newpass1">
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default" @click="resetpass()">确认修改</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
</div>

</body>
<script>



    // 创建 Vue 实例，得到 ViewModel
    var vm = new Vue({
        el: '#app',
        data: {
            info: 'sa',
            password: "",
            newpass: "",
            newpass1: "",
        },
        mounted() {
            axios({
                method: 'get',
                url: 'http://localhost:8080/checklogin',
            }) .then(function (response) {
                if (response.data.code==200){
                    window.location.href="/login.html";
                }

            })
                .catch(function (error) {
                    console.log(error);
                });
        },
        methods: {
            resetpass() {
                let param = new URLSearchParams()
                param.append('password', this.password),
                    param.append('newpass', this.newpass),
                    param.append('newpass1', this.newpass1),
                    axios({
                        method: 'post',
                        url: 'http://localhost:8080/resetPass',
                        data: param
                    }) .then(function (response) {

                        this.info=response.data
                        if (this.info.code==100){
                            alert("密码修改成功")
                        }else{
                            alert(this.info.msg)
                        }

                    })
                        .catch(function (error) {
                            console.log(error);
                        });



            },
            uptable(a){
                if(confirm('确定要删除吗？')){

                    axios.get('http://localhost:8080/uptable', {
                        params: {
                            name:a
                        }
                    })
                        .then(response => (this.info = response.data))
                        .catch(function (error) {
                            console.log(error);
                        });

                }else{

                }

            },


        }
    });
</script>
</html>